import request from '@/utils/zyrequest'
import { getToken } from '@/utils/auth'

export default {
    // 查询权限
    getList(type,pid) {
        return request({
            url: '/item/permission',
            method: 'get',
            params: {
                type:  `${type}`,
                pid: `${pid}`
            }
        })
    },

    findPermissionById(id) {
        return request({
            url: `/item/permission/${id}`,
            method: 'get'
        })
    },

    // 新增
    save(formdata) {
        return request({
            url: '/item/permission',
            method: 'post',
            data: JSON.stringify(formdata),
            headers: {
                'Content-Type': 'application/json;charset=UTF-8'
                // 'token': getToken()
            }
        })
    },

    // 保存
    update(id,formdata) {
        return request({
            url: `/item/permission/${id}`,
            method: 'put',
            data: JSON.stringify(formdata),
            headers: {
                'Content-Type': 'application/json;charset=UTF-8'
                // 'token': getToken()
            }
        })
    },

    // 删除权限
    deleteById(id) {
        return request({
            url: `/item/permission/${id}`,
            method: 'delete'
        })
    }

}